package java3_29;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;

/**
 *2:计算当前时间距“世界末日”已经过去了多少天（2012-12-21）
 */
public class Homework2 {
    public static void main(String[] args) {
//        String time = "2012-12-21";
//        Date d = new Date();
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(d);
//
//        String time1 =format.format(d);//当前时间
//        System.out.println(time1);
        LocalDate endOfWorld = LocalDate.of(2012, 12, 21);
        LocalDate today = LocalDate.now();
        long daysBetween = ChronoUnit.DAYS.between(endOfWorld, today);
        System.out.println("当前时间距世界末日: " + daysBetween+"天");
    }
}
